package Dao;

import Utils.DruidUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UpdateManagerDao {
    public static void Update(String username, String password2) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = DruidUtils.getConnection();
            String sql = "update manager set password = ? where username = ?";
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, password2);
            pstmt.setString(2, username);
            int i = pstmt.executeUpdate();
            if (i > 0) {
                System.out.println("更新成功!");
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            DruidUtils.close(pstmt, conn);
        }
    }
}
